%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/conditions/archived-forum-inherited-messages.stream-6"
    Bucket0("Bucket 0 (root)<br /><br />1: <br />ᐳ: 6, 9, 10, 29, 30, 81, 82, 83, 11, 13, 28, 32<br />2: PgSelect[8]<br />3: PgSelectRows[14]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 11, 28, 32, 29, 30, 6<br /><br />ROOT __Item{1}ᐸ14ᐳ[15]"):::bucket
    Bucket2("Bucket 2 (nullableBoundary)<br />Deps: 16, 11, 28, 32, 29, 30, 6<br /><br />ROOT PgSelectSingle{1}ᐸforumsᐳ[16]<br />1: <br />ᐳ: 17, 19, 25<br />2: PgSelect[20]<br />3: Connection[24]"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 24, 20, 11, 19, 25, 28, 32, 29, 30, 6<br /><br />ROOT Connection{2}ᐸ20ᐳ[24]<br />1: ConnectionItems[33]<br />ᐳ: Access[55]<br />2: __CloneStream[40], __CloneStream[41]"):::bucket
    Bucket6("Bucket 6 (defer)<br />Deps: 24, 11, 19, 25, 28, 32<br /><br />1: PgSelect[43]<br />ᐳ: PageInfo[42], Access[52], Access[53]<br />2: PgSelectRows[45]<br />ᐳ: 44, 46, 47"):::bucket
    Bucket7("Bucket 7 (listItem)<br />Deps: 11<br /><br />ROOT __Item{7}ᐸ40ᐳ[48]"):::bucket
    Bucket8("Bucket 8 (listItem)<br />Deps: 55, 11<br /><br />ROOT __Item{8}ᐸ41ᐳ[50]"):::bucket
    Bucket9("Bucket 9 (nullableBoundary)<br />Deps: 49, 11<br /><br />ROOT PgSelectSingle{7}ᐸmessagesᐳ[49]<br />1: <br />ᐳ: 54, 57<br />2: PgSelect[58]<br />3: PgSelectRows[63]<br />ᐳ: First[62], PgSelectSingle[64]"):::bucket
    Bucket10("Bucket 10 (nullableBoundary)<br />Deps: 50, 51, 11, 56<br /><br />ROOT Edge{8}[51]"):::bucket
    Bucket11("Bucket 11 (nullableBoundary)<br />Deps: 64<br /><br />ROOT PgSelectSingle{9}ᐸusersᐳ[64]"):::bucket
    Bucket12("Bucket 12 (nullableBoundary)<br />Deps: 65, 11<br /><br />ROOT PgSelectSingle{10}ᐸmessagesᐳ[65]<br />1: <br />ᐳ: 67, 69<br />2: PgSelect[70]<br />3: PgSelectRows[75]<br />ᐳ: First[74], PgSelectSingle[76]"):::bucket
    Bucket13("Bucket 13 (nullableBoundary)<br />Deps: 76<br /><br />ROOT PgSelectSingle{12}ᐸusersᐳ[76]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket2
    Bucket2 --> Bucket3
    Bucket3 --> Bucket6 & Bucket7 & Bucket8
    Bucket7 --> Bucket9
    Bucket8 --> Bucket10
    Bucket9 --> Bucket11
    Bucket10 --> Bucket12
    Bucket12 --> Bucket13

    %% plan dependencies
    PgSelect8[["PgSelect[8∈0] ➊<br />ᐸforumsᐳ<br />More deps:<br />- Object[11]"]]:::plan
    Lambda13{{"Lambda[13∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'EXCLUSIVELY' ]ᐳ[82]"}}:::plan
    Lambda13 --> PgSelect8
    Object11{{"Object[11∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ<br />Dependents: 5"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access10{{"Access[10∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access9 & Access10 --> Object11
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access9
    __Value2 --> Access10
    PgSelectRows14[["PgSelectRows[14∈0] ➊"]]:::plan
    PgSelect8 --> PgSelectRows14
    Lambda28{{"Lambda[28∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />Dependents: 2<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[83]"}}:::plan
    Lambda32{{"Lambda[32∈0] ➊<br />ᐸresolveStreamDetailsᐳ<br />Dependents: 4<br />More deps:<br />- Constantᐸ[HIDDEN]ᐳ[81]"}}:::plan
    __Item15[/"__Item[15∈1]<br />ᐸ14ᐳ"\]:::itemplan
    PgSelectRows14 ==> __Item15
    PgSelectSingle16{{"PgSelectSingle[16∈1]<br />ᐸforumsᐳ"}}:::plan
    __Item15 --> PgSelectSingle16
    PgSelect20[["PgSelect[20∈2]<br />ᐸmessages+1ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]<br />- Lambda[32]<br />- Lambda[32]"]]:::plan
    PgClassExpression19{{"PgClassExpression[19∈2]<br />ᐸ__forums__.”id”ᐳ"}}:::plan
    PgClassExpression25{{"PgClassExpression[25∈2]<br />ᐸ__forums__...chived_at”ᐳ"}}:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect20
    PgClassExpression17{{"PgClassExpression[17∈2]<br />ᐸ__forums__.”name”ᐳ"}}:::plan
    PgSelectSingle16 --> PgClassExpression17
    PgSelectSingle16 --> PgClassExpression19
    Connection24[["Connection[24∈2]<br />ᐸ20ᐳ"]]:::plan
    PgSelect20 --> Connection24
    PgSelectSingle16 --> PgClassExpression25
    ConnectionItems33[["ConnectionItems[33∈3]"]]:::plan
    Connection24 --> ConnectionItems33
    __CloneStream40[["__CloneStream[40∈3@s]"]]:::plan
    ConnectionItems33 --> __CloneStream40
    __CloneStream41[["__CloneStream[41∈3@s]"]]:::plan
    ConnectionItems33 --> __CloneStream41
    Access55{{"Access[55∈3]<br />ᐸ20.cursorDetailsᐳ"}}:::plan
    PgSelect20 --> Access55
    PgSelect43[["PgSelect[43∈6]<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Object[11]<br />- Lambda[28]<br />- Lambda[32]<br />- Lambda[32]"]]:::plan
    PgClassExpression19 & PgClassExpression25 --> PgSelect43
    PageInfo42{{"PageInfo[42∈6]"}}:::plan
    Connection24 --> PageInfo42
    First44{{"First[44∈6]"}}:::plan
    PgSelectRows45[["PgSelectRows[45∈6]"]]:::plan
    PgSelectRows45 --> First44
    PgSelect43 --> PgSelectRows45
    PgSelectSingle46{{"PgSelectSingle[46∈6]<br />ᐸmessagesᐳ"}}:::plan
    First44 --> PgSelectSingle46
    PgClassExpression47{{"PgClassExpression[47∈6]<br />ᐸcount(*)ᐳ"}}:::plan
    PgSelectSingle46 --> PgClassExpression47
    Access52{{"Access[52∈6]<br />ᐸ24.hasNextPageᐳ"}}:::plan
    PageInfo42 o--o Access52
    Access53{{"Access[53∈6]<br />ᐸ24.hasPreviousPageᐳ"}}:::plan
    Access52 o--o Access53
    __Item48[/"__Item[48∈7]<br />ᐸ40ᐳ"\]:::itemplan
    __CloneStream40 ==> __Item48
    PgSelectSingle49{{"PgSelectSingle[49∈7]<br />ᐸmessagesᐳ"}}:::plan
    __Item48 --> PgSelectSingle49
    Edge51{{"Edge[51∈8]"}}:::plan
    __Item50[/"__Item[50∈8]<br />ᐸ41ᐳ"\]:::itemplan
    PgCursor56{{"PgCursor[56∈8]"}}:::plan
    __Item50 & PgCursor56 --> Edge51
    __Item50 & Access55 --> PgCursor56
    __CloneStream41 ==> __Item50
    PgSelect58[["PgSelect[58∈9]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression57{{"PgClassExpression[57∈9]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression57 --> PgSelect58
    PgClassExpression54{{"PgClassExpression[54∈9]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle49 --> PgClassExpression54
    PgSelectSingle49 --> PgClassExpression57
    First62{{"First[62∈9]"}}:::plan
    PgSelectRows63[["PgSelectRows[63∈9]"]]:::plan
    PgSelectRows63 --> First62
    PgSelect58 --> PgSelectRows63
    PgSelectSingle64{{"PgSelectSingle[64∈9]<br />ᐸusersᐳ"}}:::plan
    First62 --> PgSelectSingle64
    PgSelectSingle65{{"PgSelectSingle[65∈10]<br />ᐸmessagesᐳ"}}:::plan
    __Item50 --> PgSelectSingle65
    PgClassExpression66{{"PgClassExpression[66∈11]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle64 --> PgClassExpression66
    PgClassExpression68{{"PgClassExpression[68∈11]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression66 o--o PgClassExpression68
    PgSelect70[["PgSelect[70∈12]<br />ᐸusersᐳ<br />More deps:<br />- Object[11]"]]:::plan
    PgClassExpression69{{"PgClassExpression[69∈12]<br />ᐸ__messages...author_id”ᐳ"}}:::plan
    PgClassExpression69 --> PgSelect70
    PgClassExpression67{{"PgClassExpression[67∈12]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle65 --> PgClassExpression67
    PgSelectSingle65 --> PgClassExpression69
    First74{{"First[74∈12]"}}:::plan
    PgSelectRows75[["PgSelectRows[75∈12]"]]:::plan
    PgSelectRows75 --> First74
    PgSelect70 --> PgSelectRows75
    PgSelectSingle76{{"PgSelectSingle[76∈12]<br />ᐸusersᐳ"}}:::plan
    First74 --> PgSelectSingle76
    PgClassExpression77{{"PgClassExpression[77∈13]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle76 --> PgClassExpression77
    PgClassExpression78{{"PgClassExpression[78∈13]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression77 o--o PgClassExpression78

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect8,Access9,Access10,Object11,Lambda13,PgSelectRows14,Lambda28,Lambda32 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item15,PgSelectSingle16 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,PgClassExpression17,PgClassExpression19,PgSelect20,Connection24,PgClassExpression25 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,ConnectionItems33,__CloneStream40,__CloneStream41,Access55 bucket3
    classDef bucket6 stroke:#ff1493
    class Bucket6,PageInfo42,PgSelect43,First44,PgSelectRows45,PgSelectSingle46,PgClassExpression47,Access52,Access53 bucket6
    classDef bucket7 stroke:#808000
    class Bucket7,__Item48,PgSelectSingle49 bucket7
    classDef bucket8 stroke:#dda0dd
    class Bucket8,__Item50,Edge51,PgCursor56 bucket8
    classDef bucket9 stroke:#ff0000
    class Bucket9,PgClassExpression54,PgClassExpression57,PgSelect58,First62,PgSelectRows63,PgSelectSingle64 bucket9
    classDef bucket10 stroke:#ffff00
    class Bucket10,PgSelectSingle65 bucket10
    classDef bucket11 stroke:#00ffff
    class Bucket11,PgClassExpression66,PgClassExpression68 bucket11
    classDef bucket12 stroke:#4169e1
    class Bucket12,PgClassExpression67,PgClassExpression69,PgSelect70,First74,PgSelectRows75,PgSelectSingle76 bucket12
    classDef bucket13 stroke:#3cb371
    class Bucket13,PgClassExpression77,PgClassExpression78 bucket13

